// PARADIME INTERPRETER
//
//LICENSED FREELY UNDER MIT.
//CREATED FOR FREE USE.



//Important Definitions

//From parser_eval.cpp ######################################
int GetPrecedence(char c);
void Shunt_Test(void);
int HexToDec(const char *szHex, int &nDec);
token GetTokenRepresentation(Variant* var);
int IsTrue(token* tok);
//Expression evaluation
token EvaluateRPN(std::vector<token> exp, Interpreter* QueryOwner);
std::vector<token> ShuntExpression(std::vector<token>* exp, Interpreter* QueryOwner);
//Operations !!!(Converting token types)!!!
token Addition( token tTemp2, token tTemp1);
token Subtraction( token tTemp2, token tTemp1);
token SubtractionReverse(token tTemp2, token tTemp1);
token Concat( token tTemp2, token tTemp1);
token Multiplication(token tTemp2,token tTemp1);
token DivisionReverse(token tTemp2, token tTemp1);
token Division(token tTemp1, token tTemp2);
//Comparison operators
token Equality(token tTemp1,token tTemp2);
token CASEEquality(token tTemp1,token tTemp2);
token GreaterLessThan(token tTemp1,token tTemp2);
token GreaterLessThanEqual(token tTemp1,token tTemp2);
token Difference(token tTemp1,token tTemp2);





//From Parser.cpp ######################################
int ExecuteCode(std::vector<token>* code, Interpreter* CodeOwner, int* codepos, VariableDomain* domain, char context='\0');
int Parse_GlobalDeclaration(std::vector<token>*, int*, Interpreter*, VariableDomain*);
int Parse_ArraySubscripts(int* subs, std::vector<token>*, int*, Interpreter*, VariableDomain*);
void Free_Token_Attributes(token* tok);
void Destroy_Vector_Elements(std::vector<token>* in);

#define PCONTEXT_STANDARD_EXEC '\0'
#define PCONTEXT_IFBLOCK_EXEC 'I'
#define PCONTEXT_IFLINE_EXEC 'A'
#define PCONTEXT_IFBLOCK_PASS 'P'
#define PCONTEXT_IFBLOCK_IGNORE 'O'
#define PCONTEXT_WHILEBLOCK_PASS 'W'
#define PCONTEXT_WHILEBLOCK_EXEC 'Y'


//From parser_func.cpp #################################
int Parser_FuncCallExec(token* result,std::vector<token>* exp, int* iterator, Interpreter* CodeOwner);
void InitBuiltinTable_Defaults(std::map<std::string,int (*)(token* ,std::vector<token>*,Interpreter* CodeOwner)>* table);
void* LookupBuiltin(Interpreter* CodeOwner, std::string name);
token Parser_ReturnMacro(char* name);

//!!!(Converting token types)!!!!!!!!!!!!!!!!
void Token_ForceStrType( token* tok);
void Token_ForceInt32Type( token* tok);
void Token_ForceDoubleType( token* tok);



//GeneralFunctions.cpp ##################################
int Builtin_ConsoleWrite(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_MsgBox(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_StringLen(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_StringLeft(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_StringRight(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_StringMid(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_StringTrimLeft(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_StringTrimRight(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_FileOpen(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_FileClose(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_FileRead(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_TimerInit(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);
int Builtin_TimerDiff(token* result, std::vector<token>* parameters,Interpreter* CodeOwner);